<?php 

   $fbconfig['appid' ] = "481900468602192";
   $fbconfig['secret'] = "a0dcc12dcc4f1aa73eacc6d348dc5b55";

   $fbconfig['baseUrl']    =  HTML_BASE; 
   $fbconfig['appBaseUrl'] =  "https://apps.facebook.com/rehau_bgradio/";
	
    if (isset($_GET['code'])){
        header("Location: " . $fbconfig['appBaseUrl']);
        exit;
    }
   
   
    require "facebook.php";
    
 


$facebook = new Facebook(array(
      'appId'  => $fbconfig['appid'],
      'secret' => $fbconfig['secret'],
      'cookie' => true
    ));

    //Facebook Authentication part
    $user = $facebook->getUser();
    

 $loginUrl = $facebook->getLoginUrl();

if ($user) {
	
	$like_page = $facebook->api( array(
                         'method' => 'pages.isFan',
                         'page_id' => '570326972985204',
						 'uid' => $user,
                     ));
	  
  try {
	 $logoutUrl = $facebook->getLogoutUrl();
	 $user = $facebook->getUser();
     $user_profile = $facebook->api('/me');
 			
	  
  } catch (FacebookApiException $e) {
	  
   
  }
  
 
}

$signed_request = $facebook->getSignedRequest();

$page_id = $signed_request["page"]["id"];

$page_admin = $signed_request["page"]["admin"];

$like_status = $signed_request["page"]["liked"];  
if($_GET["like"])
{
	$like_status = $_GET["like"];
}

if($like_page) $like_status = $like_page;
?>